<?php

namespace App\Notifications\OrderNotifications;

use App\Models\Master;
use App\Models\Merchant;
use App\Models\Order;
use App\Notifications\Channels\SmsChannel;
use App\Notifications\OrderNotification;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;

class OrderFinishedNotification extends Notification implements OrderNotification
{
    use Queueable;

    private $order;

    /**
     * Create a new notification instance.
     *
     * @return void
     */
    public function __construct(Order $order)
    {
        $this->order = $order;
    }

    /**
     * Get the notification's delivery channels.
     *
     * @param  mixed  $notifiable
     * @return array
     */
    public function via($notifiable)
    {
        return [SmsChannel::class];
    }

    /**
     * 发送短信
     * @param Master $master
     * @return array($phoneNum,$message)
     */
    public function toSms(Merchant $merchant)
    {
        $message = <<<EOT
【%s】您的家具服务订单%s,%s(%s）已经操作完成服务，请您尽快验收并确认付款，%d天内未确认系统将默认放款给师傅。
EOT;
        $message = sprintf($message,
            config('app.name'),
            $this->order->order_number,
            $this->order->master->call_name,
            $this->order->master->phone,
            config('common.auto_pay_days'));
        return [$merchant->me_phone,$message];
    }
}
